﻿<?php
session_start();
include("admin_resist_mdl.php");
?>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<?php

include("../../Modules/conn.php");

$msbm = $_POST["txtMSBM"];
$makhoa = $_POST["cboKhoa"];
$tenbm = $_POST["txtTenBM"];
$mk = $_POST["txtMK1"];
$mkmh = md5($mk);

// Kiem tra ma bo mon co bi trung hay khong
$queryMSBM = "select MSBM from bo_mon where MSBM = '$msbm'";
$resultMSBM = mysql_query($queryMSBM, $conn) or die(mysql_error());
$count = mysql_num_rows($resultMSBM);

if ($count > 0)
{
	header("Location: ../View/admin_cpanel.php?part=addcnbm&info=dupmsbm");
}
else
{
	// Them bo mon
	$queryInsCNBM = "insert into bo_mon(MSBM, MA_KHOA, TEN_BM, MATKHAU) values ('$msbm', '$makhoa', '$tenbm', '$mkmh')";
	mysql_query($queryInsCNBM, $conn) or die(mysql_error());
	
	mysql_close();
	header("Location: ../View/admin_cpanel.php?info=addcnbmsucc");
}

?>